home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Demos / Simpsons Cartoon Studio™ Demo / Simpdata / simpmain / 00006_listManager parent.ls < prev    next >
Encoding:
Text File  |  1996-09-06  |  5.2 KB  |  201 lines

  1. global scoreData, bgdData, fgdFXData, bgdFXData, soundFXData, soundLoopData, currentFrame
  2.  
  3. on birth me
  4.   reset(me)
  5.   return me
  6. end
  7.  
  8. on reset me
  9.   resetScoreData(me)
  10.   resetBgdData(me)
  11.   resetFgdFXData(me)
  12.   resetBgdFXData(me)
  13.   resetSoundFXData(me)
  14.   resetSoundLoopData(me)
  15. end
  16.  
  17. on resetScoreData me
  18.   set scoreData to [[[], [], [], [], [], [], [], [], [], [], [], []]]
  19. end
  20.  
  21. on resetBgdData me
  22.   set bgdData to [[5051, 313, 243]]
  23.   set theBackground to getAt(bgdData, 1)
  24.   set the castNum of sprite 1 to getAt(theBackground, 1)
  25.   set the locH of sprite 1 to getAt(theBackground, 2)
  26.   set the locV of sprite 1 to getAt(theBackground, 3)
  27. end
  28.  
  29. on resetFgdFXData me
  30.   set fgdFXData to [[]]
  31. end
  32.  
  33. on resetBgdFXData me
  34.   set bgdFXData to [[EMPTY, 0]]
  35. end
  36.  
  37. on resetSoundFXData me
  38.   set soundFXData to [[EMPTY, 0]]
  39. end
  40.  
  41. on resetSoundLoopData me
  42.   set soundLoopData to [[EMPTY, 0]]
  43. end
  44.  
  45. on addFrame me, theFrame, curDataChannel
  46.   set emptyFrameList to [[], [], [], [], [], [], [], [], [], [], [], []]
  47.   if currentFrame > count(scoreData) then
  48.     setAt(scoreData, currentFrame, copyList(emptyFrameList))
  49.   end if
  50.   setAt(getAt(scoreData, currentFrame), curDataChannel, theFrame)
  51. end
  52.  
  53. on addFrames me, startFrame, theFrames, curDataChannel
  54.   set emptyFrameList to [[], [], [], [], [], [], [], [], [], [], [], []]
  55.   set theFrameNumber to startFrame
  56.   repeat with theFrame in theFrames
  57.     if theFrameNumber > count(scoreData) then
  58.       setAt(scoreData, theFrameNumber, copyList(emptyFrameList))
  59.     end if
  60.     setAt(getAt(scoreData, theFrameNumber), curDataChannel, theFrame)
  61.     set theFrameNumber to theFrameNumber + 1
  62.   end repeat
  63. end
  64.  
  65. on removeFrames me, numberOfFrames
  66.   repeat with theFrame = 1 to numberOfFrames
  67.     deleteAt(scoreData, currentFrame)
  68.     if count(bgdData) >= currentFrame then
  69.       deleteAt(bgdData, currentFrame)
  70.     end if
  71.     if count(fgdFXData) >= currentFrame then
  72.       deleteAt(fgdFXData, currentFrame)
  73.     end if
  74.     if count(bgdFXData) >= currentFrame then
  75.       deleteAt(bgdFXData, currentFrame)
  76.     end if
  77.     if count(soundFXData) >= currentFrame then
  78.       deleteAt(soundFXData, currentFrame)
  79.     end if
  80.     if count(soundLoopData) >= currentFrame then
  81.       deleteAt(soundLoopData, currentFrame)
  82.     end if
  83.   end repeat
  84. end
  85.  
  86. on preloadCartoon me
  87.   updateStatusBar(1)
  88.   set thePreloadList to buildContentList(me)
  89.   set thePreviousCastNumber to 0
  90.   sort(thePreloadList)
  91.   updateStatusBar(1)
  92.   repeat with theCastNumber in thePreloadList
  93.     if theCastNumber <> thePreviousCastNumber then
  94.       preLoadCast(theCastNumber)
  95.       set thePreviousCastNumber to theCastNumber
  96.       if the preLoad of cast theCastNumber = 0 then
  97.         exit repeat
  98.       end if
  99.     end if
  100.     updateStatusBar(1)
  101.   end repeat
  102. end
  103.  
  104. on estimateCastSize me
  105.   set thePreloadList to buildContentList(me)
  106.   set estimatedCastSize to 0
  107.   set thePreviousCastNumber to 0
  108.   sort(thePreloadList)
  109.   repeat with theCastNumber in thePreloadList
  110.     if theCastNumber <> thePreviousCastNumber then
  111.       set estimatedCastSize to estimatedCastSize + the size of cast theCastNumber
  112.       set thePreviousCastNumber to theCastNumber
  113.     end if
  114.   end repeat
  115.   set listOfLists to [scoreData, bgdData, fgdFXData, bgdFXData, soundFXData, soundLoopData]
  116.   repeat with theList in listOfLists
  117.     set estimatedCastSize to estimatedCastSize + count(theList)
  118.   end repeat
  119.   return estimatedCastSize
  120. end
  121.  
  122. on buildContentList me
  123.   set thePreloadList to []
  124.   updateStatusBar(1)
  125.   set i to 1
  126.   repeat with theFrame in scoreData
  127.     repeat with theLayer in theFrame
  128.       if theLayer <> EMPTY then
  129.         set theCastNumber to getAt(theLayer, 1)
  130.         append(thePreloadList, theCastNumber)
  131.       end if
  132.     end repeat
  133.     if (i mod 100) = 0 then
  134.       updateStatusBar(1)
  135.     end if
  136.     set i to i + 1
  137.   end repeat
  138.   updateStatusBar(1)
  139.   set i to 1
  140.   repeat with theFrame in bgdData
  141.     if theFrame <> EMPTY then
  142.       set theCastNumber to getAt(theFrame, 1)
  143.       append(thePreloadList, theCastNumber)
  144.     end if
  145.     if (i mod 100) = 0 then
  146.       updateStatusBar(1)
  147.     end if
  148.     set i to i + 1
  149.   end repeat
  150.   updateStatusBar(1)
  151.   set i to 1
  152.   repeat with theFrame in fgdFXData
  153.     if theFrame <> EMPTY then
  154.       set theCastNumber to getAt(theFrame, 1)
  155.       append(thePreloadList, theCastNumber)
  156.     end if
  157.     if (i mod 100) = 0 then
  158.       updateStatusBar(1)
  159.     end if
  160.     set i to i + 1
  161.   end repeat
  162.   updateStatusBar(1)
  163.   set i to 1
  164.   repeat with theFrame in bgdFXData
  165.     if theFrame <> [EMPTY, 0] then
  166.       set theCastNumber to getAt(theFrame, 2)
  167.       append(thePreloadList, theCastNumber)
  168.     end if
  169.     if (i mod 100) = 0 then
  170.       updateStatusBar(1)
  171.     end if
  172.     set i to i + 1
  173.   end repeat
  174.   updateStatusBar(1)
  175.   set i to 1
  176.   repeat with theFrame in soundFXData
  177.     if theFrame <> [EMPTY, 0] then
  178.       set theCastNumber to getAt(theFrame, 2)
  179.       append(thePreloadList, theCastNumber)
  180.     end if
  181.     if (i mod 100) = 0 then
  182.       updateStatusBar(1)
  183.     end if
  184.     set i to i + 1
  185.   end repeat
  186.   updateStatusBar(1)
  187.   set i to 1
  188.   repeat with theFrame in soundLoopData
  189.     if theFrame <> [EMPTY, 0] then
  190.       set theCastNumber to getAt(theFrame, 2)
  191.       append(thePreloadList, theCastNumber)
  192.     end if
  193.     if (i mod 100) = 0 then
  194.       updateStatusBar(1)
  195.     end if
  196.     set i to i + 1
  197.   end repeat
  198.   updateStatusBar(1)
  199.   return thePreloadList
  200. end
  201.